package com.docker.drug.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.docker.common.annotation.Log;
import com.docker.common.core.controller.BaseController;
import com.docker.common.core.domain.AjaxResult;
import com.docker.common.enums.BusinessType;
import com.docker.drug.domain.DoctorDrugInformation;
import com.docker.drug.service.IDoctorDrugInformationService;
import com.docker.common.utils.poi.ExcelUtil;
import com.docker.common.core.page.TableDataInfo;

/**
 * 药品信息分类Controller
 * 
 * @author lin
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/drug/information")
public class DoctorDrugInformationController extends BaseController
{
    @Autowired
    private IDoctorDrugInformationService doctorDrugInformationService;

    /**
     * 查询药品信息分类列表
     */
    @PreAuthorize("@ss.hasPermi('drug:information:list')")
    @GetMapping("/list")
    public TableDataInfo list(DoctorDrugInformation doctorDrugInformation)
    {
        startPage();
        List<DoctorDrugInformation> list = doctorDrugInformationService.selectDoctorDrugInformationList(doctorDrugInformation);
        return getDataTable(list);
    }

    /**
     * 导出药品信息分类列表
     */
    @PreAuthorize("@ss.hasPermi('drug:information:export')")
    @Log(title = "药品信息分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DoctorDrugInformation doctorDrugInformation)
    {
        List<DoctorDrugInformation> list = doctorDrugInformationService.selectDoctorDrugInformationList(doctorDrugInformation);
        ExcelUtil<DoctorDrugInformation> util = new ExcelUtil<DoctorDrugInformation>(DoctorDrugInformation.class);
        util.exportExcel(response, list, "药品信息分类数据");
    }

    /**
     * 获取药品信息分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('drug:information:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(doctorDrugInformationService.selectDoctorDrugInformationById(id));
    }

    /**
     * 新增药品信息分类
     */
    @PreAuthorize("@ss.hasPermi('drug:information:add')")
    @Log(title = "药品信息分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DoctorDrugInformation doctorDrugInformation)
    {
        return toAjax(doctorDrugInformationService.insertDoctorDrugInformation(doctorDrugInformation));
    }

    /**
     * 修改药品信息分类
     */
    @PreAuthorize("@ss.hasPermi('drug:information:edit')")
    @Log(title = "药品信息分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DoctorDrugInformation doctorDrugInformation)
    {
        return toAjax(doctorDrugInformationService.updateDoctorDrugInformation(doctorDrugInformation));
    }

    /**
     * 删除药品信息分类
     */
    @PreAuthorize("@ss.hasPermi('drug:information:remove')")
    @Log(title = "药品信息分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(doctorDrugInformationService.deleteDoctorDrugInformationByIds(ids));
    }
}
